﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SlimDX;

namespace SCS.GFX
{
    public class Model
    {
        public string ModelName;
        public ColladaMeshObject ModelMesh;

        public Model(string name)
        {
            this.ModelName = name;
            this.ModelMesh = new ColladaMeshObject(name, new SlimDX.Vector3(0.0f, 0.0f, 0.0f));
        }

        public void Render(RenderInfo info) {
            ModelMesh.Render(info);
        }

        public void SetPosition(Vector3 pos)
        {
            ModelMesh.SetPosition(pos);
        }


    }
    static class Models
    {
        static List<Model> ModelList = new List<Model>();

        static public void Load()
        {
            Logger.WriteMsg("Loading models...");
            //Add("jabinello");
            Add("uv");
            //Add("tube");

            Logger.WriteMsg("Loading models done!");
        }

        static void Add(string name)
        {
            //only add if it's not in the list yet
            foreach (Model s in ModelList)
            {
                if (s.ModelName.Equals(name)) return;
            }

            Model m = new Model(name);
            ModelList.Add(m);

        }

        static public Model getModel(string name)
        {
            foreach (Model s in ModelList)
            {
                if (s.ModelName.Equals(name)) return s;
            }
            Logger.WriteError("getModel() failed for model " + name, "getModel()");
            return null;
        }
    }
}
